1 00:00:00,330 --> 00:00:02,340 Now let's add a local script. 2 00:00:02,340 --> 00:00:05,610 Let's add it right to our screen g ui. 3 00:00:05,640 --> 00:00:17,910 Hit the plus local script and I'm going to call this local script Run Coin award. 4 00:00:18,930 --> 00:00:20,070 There we go. 5 00:00:20,070 --> 00:00:27,630 And I need to get replicated storage so I can catch that event coming over saying, Hey, a player got 6 00:00:27,690 --> 00:00:36,570 got an award, so I need to do a local ask for replicated storage as my variable game, get service, 7 00:00:36,570 --> 00:00:38,580 replicated storage. 8 00:00:38,700 --> 00:00:43,650 Then I'm going to get a remote event and I think I'll name this one a little better. 9 00:00:43,650 --> 00:00:52,560 I'm going to call this award points r e It's going to be in replicated storage. 10 00:00:52,560 --> 00:00:55,650 We'll do a wait for child award points. 11 00:00:55,650 --> 00:01:00,720 R e The only difference is I made that lowercase and this is uppercase. 12 00:01:00,720 --> 00:01:03,210 It's got to match what is in replicated storage. 13 00:01:03,210 --> 00:01:06,540 That's just my convention of how I make my uppercase and lowercase. 14 00:01:06,540 --> 00:01:08,310 But you got to keep it consistent. 15 00:01:08,850 --> 00:01:09,210 All right. 16 00:01:09,210 --> 00:01:12,000 Now what I want to do is I want to get a sound. 17 00:01:12,000 --> 00:01:16,650 I want to get a sound that I can play when we get something. 18 00:01:16,920 --> 00:01:20,640 Let's go to our our game, my zombie game. 19 00:01:20,640 --> 00:01:27,240 Let's go to Toolbox and then click, click audio if it's not already selected. 20 00:01:27,240 --> 00:01:33,000 I was already looking for some audio and I'm going to say something like coin grab or something. 21 00:01:33,270 --> 00:01:36,000 Coin grab. 22 00:01:38,480 --> 00:01:39,500 And there's one. 23 00:01:40,550 --> 00:01:41,580 Perfect. 24 00:01:41,600 --> 00:01:42,080 Wow. 25 00:01:42,080 --> 00:01:43,070 I made it easy. 26 00:01:43,100 --> 00:01:44,750 All right, let's hit the insert. 27 00:01:46,400 --> 00:01:49,100 And it added to whatever was selected over here. 28 00:01:49,100 --> 00:01:53,960 So if it's on the wrong thing, like if it's on the award label, just go ahead and move it. 29 00:01:53,960 --> 00:01:58,460 I want it to be on my my run Coin award script. 30 00:02:00,250 --> 00:02:02,500 I'm going to change the name of my coin. 31 00:02:02,500 --> 00:02:04,390 Grab to just grab. 32 00:02:05,560 --> 00:02:06,670 Here we go. 33 00:02:07,480 --> 00:02:08,560 Grab. 34 00:02:08,560 --> 00:02:13,780 And now let's go to our Run Coin award script. 35 00:02:13,810 --> 00:02:17,650 Open that up and get a reference to that sound. 36 00:02:18,100 --> 00:02:25,480 It's a local sound and it's on the script so we can get the script variable. 37 00:02:25,840 --> 00:02:30,670 I want to do the call and wait for child because screen guys get cloned over. 38 00:02:30,670 --> 00:02:34,000 Sometimes things have to wait a little bit before they're available. 39 00:02:34,000 --> 00:02:37,900 Let's just do a wait for child grab and that's going to get the sound. 40 00:02:39,220 --> 00:02:40,870 Now let's make a function. 41 00:02:40,870 --> 00:02:44,710 We're going to do a lot of stuff in here, but right now we're just going to play that little sound. 42 00:02:44,750 --> 00:02:49,360 It'll be local function on award. 43 00:02:50,350 --> 00:02:55,600 We're also going to get the value coming over of the word like ten points or whatever it is. 44 00:02:55,600 --> 00:02:57,580 Whatever we decide, we have it at ten. 45 00:02:57,580 --> 00:02:59,380 Now let's go. 46 00:02:59,380 --> 00:03:01,410 Sound sad, right? 47 00:03:01,470 --> 00:03:06,100 We're going to get our sound variable colon play. 48 00:03:06,100 --> 00:03:09,130 So every time a word is fired, it's going to play. 49 00:03:09,640 --> 00:03:10,990 How does get fired? 50 00:03:10,990 --> 00:03:14,080 Well, we catch the remote event on this end. 51 00:03:14,080 --> 00:03:16,210 It's fired on the server side. 52 00:03:16,210 --> 00:03:23,920 We're going to do award points, Ari, and it's a dot on client event. 53 00:03:24,820 --> 00:03:29,890 Then we'll do a colon connect on award. 54 00:03:29,920 --> 00:03:32,650 If you get two extra parentheses in here, get rid of them. 55 00:03:32,650 --> 00:03:37,840 You only want the name of the function being called Let's try it out. 56 00:03:38,140 --> 00:03:39,580 Let's hit the play button. 57 00:03:43,230 --> 00:03:44,760 Now we still have our 11 there. 58 00:03:44,790 --> 00:03:46,710 Don't worry, we're going to do something with that. 59 00:03:46,710 --> 00:03:49,230 We're only going to make it up here when we need it. 60 00:03:49,260 --> 00:03:52,470 Now we've got to wait for a coin to pop up in the world. 61 00:03:52,470 --> 00:03:53,740 There's one over there. 62 00:03:53,800 --> 00:03:55,110 I'm going to go run and get it. 63 00:03:56,310 --> 00:03:57,420 I know it's really slow. 64 00:03:57,780 --> 00:03:58,650 Here we go. 65 00:03:59,790 --> 00:04:01,350 There we got our noise. 66 00:04:01,380 --> 00:04:04,500 So this is being triggered on the server side. 67 00:04:04,500 --> 00:04:07,920 We're going through our remote event, and we're hearing it on the client. 68 00:04:08,970 --> 00:04:10,140 Pretty cool. 69 00:04:12,190 --> 00:04:15,310 Let's go ahead and work on our label now. 70 00:04:16,060 --> 00:04:19,660 This label right here is only going to be a temporary thing. 71 00:04:19,660 --> 00:04:23,940 When we grab the coin, it's going to become visible and then it's going to float up out of sight. 72 00:04:23,950 --> 00:04:27,450 So I think what I'm going to do is clone it when I need it. 73 00:04:27,460 --> 00:04:32,860 I'm going to grab this and I'm going to drag this up to replicated storage. 74 00:04:33,370 --> 00:04:34,740 There we go. 75 00:04:34,750 --> 00:04:36,610 And now we don't see it. 76 00:04:36,610 --> 00:04:37,720 That's all right. 77 00:04:37,720 --> 00:04:39,220 We're going to take care of that. 78 00:04:39,220 --> 00:04:44,740 Let's open up our Run Coin award, the script. 79 00:04:44,740 --> 00:04:45,880 There we go. 80 00:04:45,880 --> 00:04:48,760 And we're going to need a few more variables. 81 00:04:48,760 --> 00:04:52,790 We're going to need a template for that little label we got. 82 00:04:52,810 --> 00:04:57,910 We might need a bunch of those little labels if we get coins quickly in a row, So we're going to have 83 00:04:57,910 --> 00:04:59,290 to clone that thing. 84 00:04:59,410 --> 00:05:08,230 I'm going to say local label temp for label template equals replicated storage. 85 00:05:08,230 --> 00:05:09,670 Wait for child. 86 00:05:09,670 --> 00:05:15,070 Now you actually have to spell this right, whatever it is in replicated storage, a ward label, that's 87 00:05:15,070 --> 00:05:16,030 how we spelt it. 88 00:05:16,630 --> 00:05:23,590 And I'm going to get something that I haven't shown you before called the tween service. 89 00:05:23,920 --> 00:05:25,360 Tween service is cool. 90 00:05:25,360 --> 00:05:29,620 You can animate movement of things within your game. 91 00:05:30,160 --> 00:05:34,990 Let's do a tween service equals game. 92 00:05:35,230 --> 00:05:38,920 Get service tween service. 93 00:05:38,920 --> 00:05:43,900 We're going to use that to move the label up out of the screen, out of view of the user. 94 00:05:44,170 --> 00:05:48,880 All right, I'm going to need one more variable, and that's for the screen. 95 00:05:49,180 --> 00:05:55,240 I'll just call it SKU and remember script dot parent, the parent will be there. 96 00:05:55,240 --> 00:05:56,920 We don't have to do a wait for child. 97 00:05:57,820 --> 00:05:58,900 Okay? 98 00:05:58,900 --> 00:06:00,760 Now we have our play. 99 00:06:00,760 --> 00:06:03,880 When we get our award, we know that's firing. 100 00:06:04,150 --> 00:06:06,310 Let's go ahead and clone our label. 101 00:06:06,310 --> 00:06:09,520 I'm going to make a variable label for label. 102 00:06:09,520 --> 00:06:20,770 I'll do label temp, colon, clone, and then label dot parent is going to be the screen. 103 00:06:21,040 --> 00:06:27,760 So we have to attach that new clone somewhere on our screen gooey label text. 104 00:06:27,760 --> 00:06:29,050 What's that going to be? 105 00:06:29,050 --> 00:06:35,110 Well, whatever came over in this vowel, remember, we have it at 11 for testing. 106 00:06:35,110 --> 00:06:43,480 So the vowel we have set to ten on the server side, I'm going to hit that little plus so it shows plus 107 00:06:43,480 --> 00:06:49,990 ten dot dot string concatenate for and then value. 108 00:06:50,440 --> 00:06:53,230 If you're a purist, you can do it just like this. 109 00:06:53,230 --> 00:06:58,270 But if you're a purist, you might want to say to string 110 00:07:00,370 --> 00:07:01,480 value. 111 00:07:01,480 --> 00:07:04,090 But the string concatenate does that for you. 112 00:07:04,090 --> 00:07:05,860 Let's keep it like that though. 113 00:07:05,890 --> 00:07:07,060 It looks fancy. 114 00:07:07,810 --> 00:07:08,320 All right. 115 00:07:08,320 --> 00:07:13,360 Now we have our value, it should say, plus ten on the label. 116 00:07:13,810 --> 00:07:16,480 Now we have to move the label up. 117 00:07:16,480 --> 00:07:18,370 Let's do local. 118 00:07:18,370 --> 00:07:30,520 I'm going to make the variable called tween and we're going to do a TS create. 119 00:07:30,760 --> 00:07:36,670 So tween servers, we're going to create a tween, we're going to tween the label. 120 00:07:36,820 --> 00:07:40,660 And then here we need something called tween info. 121 00:07:41,320 --> 00:07:47,530 We're only going to use the time the tween info gives you stuff like whether you want it to move linearly 122 00:07:47,530 --> 00:07:54,550 or bounce, or you want the bounce at the beginning or the end repeatable, reversible stuff like that. 123 00:07:54,550 --> 00:07:56,560 But I'm going to keep it really simple. 124 00:07:56,560 --> 00:08:03,400 I want to make a simple tween info dot new and just put the time in. 125 00:08:03,400 --> 00:08:03,790 Right? 126 00:08:03,790 --> 00:08:09,070 So this easing style easing direction, that was the stuff I was talking about with the movement, the 127 00:08:09,070 --> 00:08:10,300 fancy movement. 128 00:08:10,990 --> 00:08:11,440 All right. 129 00:08:11,440 --> 00:08:13,600 So we'll do a little bit more of that later. 130 00:08:14,140 --> 00:08:17,170 Let's go ahead and hit these curly brackets. 131 00:08:17,170 --> 00:08:18,730 See that You might not see that on the video. 132 00:08:18,730 --> 00:08:21,040 These are curly brackets, not square brackets. 133 00:08:21,040 --> 00:08:22,990 This is the tween goal. 134 00:08:22,990 --> 00:08:32,380 So wherever it started out to this and you can tween on position or size or color, we're going to tween 135 00:08:32,380 --> 00:08:33,940 on possession, right? 136 00:08:33,940 --> 00:08:38,560 We're going to animate the position up and out of the users view. 137 00:08:39,280 --> 00:08:48,430 Now position in the UI world, the user interface world and roadblocks uses a U dim to was a universal 138 00:08:48,430 --> 00:09:00,640 dimension of two udm two no guess what scale x scale x pixel y scale y pixel. 139 00:09:00,640 --> 00:09:07,360 So on the x, we're going to keep it at 0.5, we're going to keep it in the center zero pixel offset. 140 00:09:07,360 --> 00:09:11,110 But for the Y, the higher you go, the lower the number. 141 00:09:11,110 --> 00:09:11,620 So zero. 142 00:09:11,810 --> 00:09:13,990 I was right at the top of the screen. 143 00:09:14,000 --> 00:09:16,070 Let's make it a -0.5. 144 00:09:16,070 --> 00:09:18,560 So disappears off of the screen. 145 00:09:18,860 --> 00:09:20,740 Zero pixel offset. 146 00:09:20,750 --> 00:09:23,810 I'm going to move this to the next line so you can see it. 147 00:09:25,040 --> 00:09:25,400 All right. 148 00:09:25,400 --> 00:09:27,410 So that is our goal. 149 00:09:27,620 --> 00:09:30,060 We've got to run the tween now, right? 150 00:09:30,080 --> 00:09:31,820 So we created the tween. 151 00:09:31,820 --> 00:09:40,610 Let's do a tween colon play, and then we're going to wait until the tween is completed. 152 00:09:40,610 --> 00:09:44,120 So tween, this is crazy, Dot. 153 00:09:44,120 --> 00:09:47,720 You've got to remember, the difference is between the dots and the colons. 154 00:09:48,140 --> 00:09:55,700 So tween dot completed colon wait means we're going to wait here until the tween completes till we reach 155 00:09:55,700 --> 00:09:56,510 our goal. 156 00:09:56,510 --> 00:09:57,890 And then. 157 00:09:59,310 --> 00:10:03,090 Let's go ahead and destroy our label. 158 00:10:03,120 --> 00:10:04,520 I was going to destroy the tween. 159 00:10:04,530 --> 00:10:07,200 We want to destroy the label. 160 00:10:09,740 --> 00:10:10,640 All right. 161 00:10:11,350 --> 00:10:12,250 That should work. 162 00:10:12,250 --> 00:10:13,600 Let's try it out. 163 00:10:14,410 --> 00:10:15,520 Hit the play. 164 00:10:19,300 --> 00:10:20,220 Your little guy. 165 00:10:20,240 --> 00:10:22,220 I'm going to pause it until the coins pop up. 166 00:10:22,850 --> 00:10:23,410 There you go. 167 00:10:23,420 --> 00:10:24,320 There's a coin. 168 00:10:25,640 --> 00:10:26,400 Ha! 169 00:10:26,450 --> 00:10:27,560 That's pretty good. 170 00:10:27,590 --> 00:10:28,850 Twins move a little fast. 171 00:10:28,850 --> 00:10:30,170 We might want to slow it down. 172 00:10:31,700 --> 00:10:32,840 I think that's fine. 173 00:10:33,590 --> 00:10:36,800 If you want to slow it down, I'm going to show you it's worth it. 174 00:10:37,100 --> 00:10:40,160 If you want to slow it down, you increase your tween time. 175 00:10:40,160 --> 00:10:40,750 Right? 176 00:10:40,760 --> 00:10:41,740 There's a time. 177 00:10:41,750 --> 00:10:47,320 Maybe we'll make it 3 seconds because it is kind of going up off the screen a little bit high. 178 00:10:47,330 --> 00:10:51,770 We could actually reduce this and that will reduce the distance. 179 00:10:51,770 --> 00:10:53,600 It has to move in 2 seconds. 180 00:10:53,600 --> 00:10:55,670 So either one will speed things up. 181 00:10:55,670 --> 00:10:59,220 But I think I'm just going to make this a three and try it again. 182 00:10:59,290 --> 00:11:01,820 I'm going to pause the video till I find a coin. 183 00:11:03,180 --> 00:11:03,450 All right. 184 00:11:03,450 --> 00:11:04,500 I got a coins here. 185 00:11:04,500 --> 00:11:05,450 The minefield. 186 00:11:05,460 --> 00:11:07,530 Let's take a look at our little sign. 187 00:11:08,460 --> 00:11:09,540 Yeah, it's a little slower. 188 00:11:09,540 --> 00:11:10,410 I like that. 189 00:11:13,350 --> 00:11:14,250 All right.